home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / Gimp / Lib.pm < prev    next >
Encoding:
Perl POD Document  |  2003-01-14  |  2.2 KB  |  114 lines

  1. package Gimp::Lib;
  2.  
  3. use strict;
  4. use vars qw($VERSION @ISA);
  5.  
  6. BEGIN {
  7.    $VERSION = 1.211;
  8.    eval {
  9.       require XSLoader;
  10.       XSLoader::load Gimp::Lib $VERSION;
  11.    } or do {
  12.       require DynaLoader;
  13.       @ISA=qw(DynaLoader);
  14.       bootstrap Gimp::Lib $VERSION;
  15.    }
  16. }
  17.  
  18. use subs qw(
  19.     gimp_call_procedure        gimp_main    gimp_init
  20.     _gimp_procedure_available    set_trace    gimp_end
  21.         initialized
  22. );
  23.  
  24. sub gimp_init {
  25.    Gimp::croak Gimp::_("gimp_init not implemented for the Lib interface");
  26. }
  27.  
  28. sub gimp_end {
  29.    Gimp::croak Gimp::_("gimp_end not implemented for in the Lib interface");
  30. }
  31.  
  32. sub lock {
  33.    # unimplemented, ignored
  34. }
  35.  
  36. sub unlock {
  37.    # unimplemented, ignored
  38. }
  39.  
  40. sub import {}
  41.  
  42. # functions to "autobless" where the autobless mechanism
  43. # does not work.
  44.  
  45. sub gimp_image_list {
  46.    map _autobless($_,&Gimp::PDB_IMAGE),gimp_call_procedure "gimp_image_list";
  47. }
  48.  
  49. sub gimp_image_get_layers {
  50.    map _autobless($_,&Gimp::PDB_LAYER),gimp_call_procedure "gimp_image_get_layers",@_;
  51. }
  52.  
  53. sub gimp_image_get_channels {
  54.    map _autobless($_,&Gimp::PDB_CHANNEL),gimp_call_procedure "gimp_image_get_channels",@_;
  55. }
  56.  
  57. # "server-side" perl code evaluation
  58. sub server_eval {
  59.    my @res = eval shift;
  60.    die $@ if $@;
  61.    @res;
  62. }
  63.  
  64. # this is here to be atomic over the perl-server
  65. sub _gimp_append_data($$) {
  66.    gimp_set_data ($_[0], gimp_get_data ($_[0]) . $_[1]);
  67. }
  68.  
  69. # convinience functions
  70. sub gimp_drawable_pixel_rgn($$$$$$) {
  71.    Gimp::gimp_pixel_rgn_init(@_);
  72. }
  73.  
  74. sub gimp_progress_init {
  75.    if (@_<2) {
  76.       goto &_gimp_progress_init;
  77.    } else {
  78.       eval { gimp_call_procedure "gimp_progress_init",@_ };
  79.       gimp_call_procedure "gimp_progress_init",shift if $@;
  80.    }
  81. }
  82.  
  83. sub gimp_drawable_bounds {
  84.    my @b = (shift->mask_bounds)[1..4];
  85.    (@b[0,1],$b[2]-$b[0],$b[3]-$b[1]);
  86. }
  87.  
  88. 1;
  89. __END__
  90.  
  91. =head1 NAME
  92.  
  93. Gimp::Lib - Interface to libgimp (as opposed to Gimp::Net)
  94.  
  95. =head1 SYNOPSIS
  96.  
  97.   use Gimp; # internal use only
  98.  
  99. =head1 DESCRIPTION
  100.  
  101. This is the package that interfaces to The Gimp via the libgimp interface,
  102. i.e. the normal interface to use with the Gimp. You don't normally use this
  103. module directly, look at the documentation for the package "Gimp".
  104.  
  105. =head1 AUTHOR
  106.  
  107. Marc Lehmann <pcg@goof.com>
  108.  
  109. =head1 SEE ALSO
  110.  
  111. perl(1), L<Gimp>.
  112.  
  113. =cut
  114.